package com.data.web.config;


import com.data.biz.domain.*;
import com.data.biz.mapper.*;
import com.data.biz.service.impl.BizAccservice;
import com.data.biz.service.impl.BizDipservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Configuration
public class Test {

    @Autowired
    private FunctionModelMapper functionModelMapper;

    @Autowired
    private WindPointMapper windPointMapper;

    @Autowired
    private DipDataMapperEx dipDataMapperEx;

    @Autowired
    private AccDataMapper accDataMapper;

    @Autowired
    private AccDataMapperEx accDataMapperEx;

    @Autowired
    private DipDataMapper dipDataMapper;

    @Autowired
    private BizAccservice accservice;

    @Autowired
    private BizDipservice dipservice;

    @Autowired
    private TableCreateMapper tableCreateMapper;


//    @PostConstruct
    public void testCreateTalbe(){
//        tableCreateMapper.createDipTable("123_123_44");
        int aa = tableCreateMapper.checkIfTableExist("123_123_44");
        System.out.println(aa);
    }
    //    @PostConstruct
    public List<WindPoint> selectPoints() {

        WindPointExample example = new WindPointExample();
        WindPointExample.Criteria criteria = example.createCriteria();
        List<WindPoint> list = windPointMapper.selectByExample(example);
        System.out.println();
        return list;
    }

//    @PostConstruct
    public List<FunctionModel> selectFunctionModelList() {
        List<FunctionModel> list = functionModelMapper.selectByExample();
        System.out.println();
        return list;
    }

//    @PostConstruct
    public void batchInsert() {
        List<AccData> list = new ArrayList<>();
        AccData data = new AccData();
        data.setId(99998l);
        data.settMean(new BigDecimal(10));
        list.add(data);
        accDataMapperEx.batchInsert(list,"123_456_677_111_acc_com8");
        System.out.println();
    }

    public static void main(String[] args){
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        System.out.println(list.get(list.size()-1));

    }

//    @PostConstruct
    public void testTotalCount(){
        AccDataExample example = new AccDataExample();
        AccDataExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(1137l);
        List<AccData> list = accDataMapper.selectByExample(example);
        WindPoint point = windPointMapper.selectByPrimaryKey(2);
        accservice.setLastData(point,list);
    }


    
//        @PostConstruct
    public void testTotalCountForDip(){
        DipDataExample example = new DipDataExample();
        DipDataExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(1182l);
        List<DipData> list = dipDataMapper.selectByExample(example);
        WindPoint point = windPointMapper.selectByPrimaryKey(1);
        dipservice.setLastData(point,list);
    }

}
